home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / parcs / parcs.lha / sample / send.parcs < prev    next >
Text File  |  1992-06-08  |  990b  |  48 lines

  1. defdomain from0to9 int{0..9}.
  2. defdomain from0to1 int{0..1}.
  3.  
  4. send([S,E,N,D,M,O,R,Y],[R1,R2,R3,R4]) :-
  5.     from0to9(S,E,N,D,M,O,R,Y),
  6.     from0to1(R1,R2,R3,R4),
  7.     alldif([S,E,N,D,M,O,R,Y]),
  8. /*    S!=E,S!=N,E!=N,S!=D,S!=M,S!=O,S!=R,S!=Y,*/
  9.     S!=0,
  10.     M!=0,
  11.     R2+S+M = O+10*R1,
  12.     R3+E+O = N+10*R2,
  13.     R4+N+R = E+10*R3,
  14.     D+E    = Y+10*R4,
  15.     R1==M.
  16.  
  17. defdomain from1to5 int{1..5}.
  18.  
  19. houses([N1,N2,N3,N4,C5,C1,C2,C3,C4,C5,P1,P2,P3,P4,P5,A1,A2,A3,A4,A5,D1,D2,D3,D4,D5]) :-
  20.  
  21.     from1to5(N1,N2,N3,N4,C5,C1,C2,C3,C4,C5,P1,P2,P3,P4,P5,A1,A2,A3,A4,A5,D1,D2,D3,D4,D5),
  22.     N1=C2,N2=A1,N3=P1,N4=D3,N5=1,D5=3,P3=D1,C1=D4,P5=A4,P2=C3,
  23.     C1=C5+1,
  24.     plusorminus1(A3,P4),
  25.     plusorminus1(A5,P2),
  26.     plusorminus1(1,C4),
  27.     alldif([N1,N2,N3,N4,N5]),
  28.     alldif([C1,C2,C3,C4,C5]),
  29.     alldif([P1,P2,P3,P4,P5]),
  30.     alldif([A1,A2,A3,A4,A5]),
  31.     alldif([D1,D2,D3,D4,D5]).
  32.  
  33.  
  34. plusorminus1(X,Y) :- X = Y-1.
  35.  
  36. plusorminus1(X,Y) :- X = Y+1.
  37.  
  38. alldif([]).
  39. alldif([A|X]) :- different(A,X),alldif(X).
  40.  
  41. different(A,[]).
  42. different(A,[B|X]) :- A!=B ,different(A,X).
  43.  
  44.  
  45.  
  46.  
  47.  
  48.